// models/va.js
module.exports = (sequelize, DataTypes) => {
    const VA = sequelize.define('VA', {
        id: {
            type: DataTypes.INTEGER,
            autoIncrement: true,
            primaryKey: true
        },
        name: {
            type: DataTypes.STRING,
            allowNull: false
        }
    }, {
        tableName: 'VA',  // 对应数据库中的 VAs 表
        timestamps: false
    });


    VA.associate = (models) => {
        VA.belongsToMany(models.Product, {
            through: models.ProductVA,
            foreignKey: 'vaID',
            otherKey: 'rjCode',
            as: 'products'
        });
    };

    return VA;
};
